package com.weiyuwqj.server.service.asset.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.weiyuwqj.api.common.PageList;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.model.SysAssetCompany;
import com.weiyuwqj.api.service.SysAssetCompanyService;
import com.weiyuwqj.server.mapper.SysAssetCompanyMapper;
import com.weiyuwqj.server.service.base.BaseServiceImpl;

/**
 * 
 * @className:SysAssetCompanyServiceImpl	
 * @Description: 资产方serviceimpl
 * @author cx
 * @date:2017年3月25日上午10:42:27 
 *
 */
@Service("sysAssetCompanyService")
public class SysAssetCompanyServiceImpl extends BaseServiceImpl<SysAssetCompany> implements SysAssetCompanyService{

	@Autowired
	private SysAssetCompanyMapper  sysAssetCompanyMapper;
	
	@Override
	public PageList getList(final Paginator p,final String name) {
		PageHelper.startPage(p.getPageNum(), p.getPageSize());
		List<SysAssetCompany> list = this.sysAssetCompanyMapper.getPageList(name);
		return new PageList(list);
	}
	
	@Override
	public List<HashMap<String,Object>> getList(){
		final List<HashMap<String,Object>> mapList = new ArrayList<HashMap<String,Object>>();
		final List<SysAssetCompany> list = this.sysAssetCompanyMapper.getList();
		if(list!=null&&!list.isEmpty()){
			HashMap<String,Object> map = null;
			for (SysAssetCompany sysAssetCompany : list) {
				map = new HashMap<String, Object>();
				map.put("id", sysAssetCompany.getId());
				map.put("name", sysAssetCompany.getName());
				mapList.add(map);
			}
		}
		return mapList;
		
	}

	@Override
	public SysAssetCompany findById(final Integer id) {
		return this.sysAssetCompanyMapper.findById(id);
	}

}
